package com.gcxy.controller;

import com.gcxy.conf.result.R;
import com.gcxy.dto.AddUserDTO;
import com.gcxy.dto.EditUserDTO;
import com.gcxy.dto.UserPageDTO;
import com.gcxy.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/account")
@Api(value = "AccountController" , tags = "人员管理控制器")
public class AccountController {
    @Autowired
    private IUserService userService;


    @ApiOperation(value = "添加用户")
    @PostMapping("/addUser")
    public R addUser(@Validated @RequestBody AddUserDTO addUserDTO){
        return userService.addUser(addUserDTO);
    }

    @ApiOperation(value = "修改用户信息")
    @PostMapping("/editUser")
    public R editUser(@Validated @RequestBody EditUserDTO editUserDTO){
        return userService.editUser(editUserDTO);
    }


    @ApiOperation(value = "删除用户")
    @DeleteMapping("/deleteUser/{userId}")
    public R deleteUser(@PathVariable String userId){
        return userService.deleteUser(userId);
    }


    @ApiOperation(value = "根据id重置用户密码123456")
    @PutMapping("/resetPassword/{userId}")
    public R resetPassword(@PathVariable String userId){
        return userService.resetPassword(userId);
    }


    @ApiOperation(value = "分页多条件查询用户")
    @PostMapping("/getUserList")
    public R getUserList(@RequestBody UserPageDTO userPageDTO){
        return userService.getUserList(userPageDTO);
    }
}
